package com.study.aop;

import com.study.aop.ann.Metrics;
import com.study.aop.entity.UserEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author zhuzi
 * 2023/9/26 15:14
 */
@Service
@Slf4j
public class UserServices {


    @Metrics //启用方法监控
    public void createUser(UserEntity entity) {
        if (entity.getName().contains("test")) {
            throw new RuntimeException("invalid username!");
        }
    }

    public int getUserCount(String name) {
        return name.length();
    }
}
